package com.java2207.group1.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.java2207.group1.bo.DischargeBo;
import com.java2207.group1.pojo.Discharge;
import com.java2207.group1.service.DischargeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 15319 2022/7/26 15:50
 */
@Component
@Scope("prototype")
public class DischargeBoListener extends AnalysisEventListener<DischargeBo> {
    @Autowired
    private DischargeService dischargeService;


    @Override
    public void invoke(DischargeBo dischargeBo, AnalysisContext analysisContext) {
        Discharge discharge = new Discharge();
        BeanUtils.copyProperties(dischargeBo,discharge);
        dischargeService.dischargeAdd(discharge);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
